<?php
class address
{
	var $address_orig;
	var $address_dis;
	// $this->connect_db();
	// function getAdressOrig($postOrig)
	// {
		
		// $sql_info = "SELECT  postcode,town FROM geo_gpc order by DESC";
		// $sql_info = "SELECT  postcode,town FROM geo_gpc where postcode ==$postOrig";	
		// $result = mysql_query($sql_info);
		// return $result['town'];
	// }
	// function getAddressDis($postDis)
	// {
		// $sql_info = "SELECT  postcode,town FROM geo_gpc where postcode ==$postDis";	
		// $result = mysql_query($sql_info);
		// return $result['town'];
	// }
	function connect_db() {
		
		$conn_str = mysql_connect('localhost', 'root', 'root');
		mysql_select_db('cabee'); // if there are problems with the tablenames inside the config file use this row 
	}
	
	function getAddressOrigin($Oripostcode) 
	{$Oripostcode="KT21 2SB";
		$sql = "SELECT street,town,county FROM local where postcode='".$Oripostcode."'";
		$r = mysql_query($sql);
		if (!$r) {
			echo $sql;
			$this->last_error = mysql_error();
         return false;
		} else {
			 $row = mysql_fetch_row($r);
			 
			 $result = $row[0].','.$row[1].','.$row[2];
			 return $result;
			}
	}
	function getAddressDest($despostcode) 
	{
		$sql = "SELECT street, town, county FROM local where postcode='".$despostcode."'";
		$r = mysql_query($sql);
		if (!$r) {
			echo $sql;
			$this->last_error = mysql_error();
         return false;
		} else {
			 $row = mysql_fetch_row($r);
			 $result = $row[0].','.$row[1].','.$row[2];
			 return $result;
			}
	}      
	
}
?>